<template>
  <n-drawer-content title="基本信息">
    <n-form
        ref="formRef"
        :model="info"
        :inline="true"
        label-placement="left"
        @keydown.enter="save"
        :label-width="80">
      <n-grid
          x-gap="12"
          :cols="2">
        <n-form-item-gi label="字典名称" path="typeName">
          <n-input v-model:value="info.typeName" placeholder="请输入字典名称" clearable />
        </n-form-item-gi>
        <n-form-item-gi label="字典代码" path="typeCode">
          <n-input v-model:value="info.typeCode" clearable />
        </n-form-item-gi>
      </n-grid>
    </n-form>
    <template #footer>
      <n-space>
        <n-button attr-type="button" @click="$emit('closeDrawer')">取消</n-button>
        <n-button type="primary" attr-type="button" @click="save">保存</n-button>
      </n-space>
    </template>
  </n-drawer-content>
</template>
<script setup >

import {onMounted, ref} from "vue";
import {getDictTypeById, updateDictType} from "@/api/system/dictApi";
const getDefaultForm=()=>({
  typeName:''
})

const info = ref(getDefaultForm());
 defineEmits({
  closeDrawer:null
})
const props = defineProps({
  selected:{
    type:null,
  }
})

const save = ()=>{
  updateDictType(info.value).then(res=>{

  })
}
const getInfo =()=>{
  getDictTypeById(props.selected.id).then(res=>{
    info.value = res.data
  })
}
onMounted(()=>{
  getInfo();
})
</script>